<?php

namespace MyExample;

use Attribute;
use ReflectionClass;

#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_FUNCTION | Attribute::TARGET_METHOD)]
class MyAttrbute
{
    public function __construct(public string $name)
    {
        echo $this->name;
    }

}

#[MyAttrbute(name: "hanjie")]
class Thing
{
}

function dumpAttributeData($reflection)
{

    $attributes = $reflection->getAttributes();

    foreach ($attributes as $attribute) {

        $attribute->newInstance();
        // var_dump($attribute->getName());
        // var_dump($attribute->getArguments());
        // var_dump($attribute->newInstance());
    }
}

dumpAttributeData(new ReflectionClass(Thing::class));
